﻿using System;
using System.IO;

namespace msilgc.common {
    public static class CudaSettings {
        public static string SystemTempFolder {
            get { return Path.GetTempPath(); }
        }

        public static string CudaBinPath {
            get {
                return IsUnix()
                    ? "/usr/bin"
                    : Path.Combine(CudaPath, "bin");
            }
        }

        public static string CudaIncludePath {
            get {
                return IsUnix()
                    ? "/usr/include"
                    : Path.Combine(CudaPath, "include");
            }
        }

        public static string CudaLibraryPath {
            get {
                return IsUnix()
                    ? "/usr/lib"
                    : Path.Combine(CudaPath, "lib\\x64");
            }
        }

        private static string CudaPath {
            get {
                return IsUnix()
                    ? "/usr/bin"
                    : EnvironmentFinder.GetValueTryDefault("CUDA_PATH", new[] { @"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0" });
            }
        }

        private static bool IsUnix() {
            switch (Environment.OSVersion.Platform) {
                case PlatformID.Win32S:
                case PlatformID.Win32Windows:
                case PlatformID.Win32NT:
                    return false;
                case PlatformID.Unix:
                case PlatformID.MacOSX:
                    return true;
                default:
                    throw new SystemException("platform is not supported");
            }
        }
    }
}